package com.sdruixinggroup.mondayb2b.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import butterknife.ButterKnife;


/**
 * Created by huangqingqing on 2016/1/6.
 */
public abstract class AbCustomHeaderView extends LinearLayout {

    private Toast toast;
    public AbCustomHeaderView(Context context) {
        super(context);
        init();
    }

    public AbCustomHeaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public AbCustomHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    // Initialize Header View
    private boolean init() {

        LayoutInflater.from(getContext()).inflate(getInflateLayout(), this);
        setUpView(this);
        ButterKnife.bind(this);
        return true;
    }


    public abstract int getInflateLayout();

    public abstract void setUpView(View view);

    public void showMsgToast(String msg) {
        if (null == toast) {
            toast = Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT);
        } else {
            toast.setText(msg);
        }
        toast.show();

    }

}
